/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.sidora.opcit.core;

import java.util.ArrayList;
import javax.swing.ImageIcon;

/**
 *
 * @author etartera
 */
public class ReferenceTableModel {
    private ArrayList <Reference> set;
	
	
	public ArrayList<Reference> getSet() {
		return set;
	}

	public void setSet(ArrayList<Reference> set) {
		this.set = set;
	}

	public ReferenceTableModel(ArrayList<Reference> set) {
		super();
		this.set = set;
	}

	public int getRowCount() {
		return set.size();
	}

	public int getColumnCount() {
		return 6;
	}

	public Object getValueAt(int fila, int column) {
		
		Reference ref = set.get(fila);
		Object obj = null;
		
		
		switch (column) {
		case 0:
			obj= ref.getAuthors();
			break;

		case 1:
			obj= ref.getYear();
			break;
			
		case 2:
			obj= ref.getType();
			break;
			
		case 3:
			obj= ref.getTitle();
			break;
			
		case 4:
			obj= ref.hasKeys();
			break;
		
		case 5:
			obj= ref.hasNotes();
			break;
			
		default:
			break;
		}
		return obj;
	}

	
	public String getColumnName(int column) {
		String name = "";
		switch (column) {
		case 0:
			name = "Autors";
			break;

		case 1:
			name = "Any";
			break;
			
		case 2:
			name = "Tipus";
			break;
			
		case 3:
			name = "Títol";
			break;
			
		case 4:
			name = "Claus";
			break;
		
		case 5:
			name = "Notes";
			break;
			
		default:
			break;
		}
		return name;
		
	}

	
	public Class<?> getColumnClass(int column) {
		Class name = Object.class;
		switch (column) {
		case 0:
			name = String.class;
			break;

		case 1:
			name = String.class;
			break;
			
		case 2:
			name = ImageIcon.class;
			break;
			
		case 3:
			name = String.class;
			break;
			
		case 4:
			name = Boolean.class;
			break;
		
		case 5:
			name = Boolean.class;
			break;
			
		default:
			break;
		}
		return name;
	}

}
